@extends('admin.inc.base')
@section('content')
    <link rel="stylesheet" type="text/css" href="/public/statics/libs/wangEditor/dist/css/wangEditor.min.css">
    <script type="text/javascript" src="/public/statics/libs/wangEditor/dist/js/wangEditor.js"></script>
    <script type="text/javascript" src="/public/statics/libs/uploader/UploadFile.js"></script>

    <div class="panel panel-default">
        <div class="panel-heading">
            编辑文章
        </div>
        <div class="panel-body">
            <form action="/admin/ad/{{$banner->id}}" method="post">
                <div class="form-group">
                    <label for="">标题</label>
                    <input type="text" class="form-control" name="title"  value="{{ $banner->title }}" placeholder="标题">
                </div>

                <div class="form-group">
                    <label for="">链接</label>
                    <input type="text" class="form-control" name="url"  value="{{ $banner->url }}" placeholder="链接">
                    <p class="help-block"></p>
                </div>

                <div class="form-group">
                    <label for="">广告位置</label>
                    <input type="text" class="form-control" name="position" value="{{ $banner->position }}"  placeholder="广告位置">
                    <p class="help-block">标志位置的数字，用于模板页面引用对应的广告。需要保证数字唯一</p>
                </div>

                <div class="form-group">
                    <label for="">banner图</label>
                    <div id="upload-img-show">
                        <img src="{{ $banner->cover }}" />
                    </div>
                    <span class="upload" id="upload">上传图片</span>
                    <input type="hidden" name="cover" id="upload-img" value="{{ $banner->cover }}" />
                </div>

                <button type="submit" class="btn btn-default">提交</button>
            </form>
        </div>
    </div>
    <script type="text/javascript">
        var upload = new Upload({
            "clickDom":"upload",
            "action":"/admin/upload",
            "onUploadSuccess":function(data){
                if(data.status == 'ok'){
                    $('#upload-img').val(data.url);
                    $("#upload-img-show").html('<img src="'+data.url+'" />');
                }else{
                    console.log(data);
                }
            }
        });
    </script>
@endsection